<template>
	<view>
		<!-- 懒加载动画 -->
		<view class="loading-box">
			<u-loading :show="loadingone" color="#41ADBA" size="70"></u-loading>
		</view>
		<dev-navbar title="健康档案"></dev-navbar>
		<!-- 卡片信息 -->
		<scroll-view :scroll-top="0" scroll-x="true"  class="head-navigation" :style="{'top':`${navAllHeight}px`}">
			<view class="every-scroll-view" v-for="(item,index) in healthCard" :key="index" @tap="switcHealthCard(item,index)">
				<!-- index ===0 后面改成当前激活的标识 第一处 -->
				<view :class="index===cardIndex?'choose-card-box':'every-card-box'">
					<dev-svg-image mode="image" :imageUrl="index===cardIndex?item.selectUrl:item.url" width="40"
						height="40"></dev-svg-image>
					<text style="margin-top: 14rpx;">{{item.name}}</text>
				</view>
				<!-- index ===0 后面改成当前激活的标识 第二处  -->
				<view v-show="index===cardIndex" class="triangle"></view>
				<view style="height: 14rpx;"></view>
			</view>
		</scroll-view>


	 <view class="overall-data" :style="{'margin-top':`${130}rpx`}">

    <!-- <scroll-view scroll-y="true" :scroll-into-view="intoView" style="min-height: 100vh;" scroll-with-animation="true"> -->

			<!--基本信息-->
			<view class="in-every-particular" id="basicInfo" key="0">
				<dev-list-layout leftText="基本信息" leftColor="#2EA7E0" padding="0rpx 20rpx" key="1" :is-right-img="false"
					backgroundColor="linear-gradient(112deg, #D8EEE8 0%, #CFEBF8 100%)">
				</dev-list-layout>

				<dev-list-layout :isRightImg="false" leftText="姓名"  padding="0rpx 20rpx" key="2" :rightText="result.basicInfo.userName">
					 <template v-slot:right>
					   <input style="text-align: right;caret-color:#37bad5;" class="flex-input" type="text" v-model="result.basicInfo.userName" @blur="nameAlter"/>
					  </template>
				</dev-list-layout>
				<dev-list-layout leftText="性别"  padding="0rpx 20rpx" key="3" :rightText="result.basicInfo.sex ==1?'男':(result.basicInfo.sex ==2?'女':'待完善')" @tap="clickInput('gender')">
				</dev-list-layout>
				<dev-list-layout leftText="生日" padding="0rpx 20rpx" key="4" :rightText="result.basicInfo.birthday || '待完善'" @tap="clickInput('birthday')">
				</dev-list-layout>
				<dev-list-layout leftText="身高"  padding="0rpx 20rpx" key="5" :rightText="result.basicInfo.height || '待完善'" @tap="clickInput('height')">
				</dev-list-layout>
				<dev-list-layout leftText="体重"  padding="0rpx 20rpx" key="6" :rightText="result.basicInfo.weight || '待完善'" @tap="clickInput('weight')">
				</dev-list-layout>
			</view>


			<!-- 性别 -->
			<lb-picker ref="sexPicker" v-model="rightText" mode="selector" :list="sexList" :dataset="{ name: 'label4' }"
										@change="handleChange" @confirm="(value)=>handleConfirm(value,'gender')" @cancel="handleCancel">
			</lb-picker>
			<!--生日-->
			<lb-picker ref="picker1"
			  v-model="result.basicInfo.birthday"
			  :start-date="starDate"
			  :end-date="endTime"
			  mode="dateSelector"
			  @change="handleChange"
			  @confirm="(value)=>handleConfirm(value,'birthday')"
			  @cancel="handleCancel">
			</lb-picker>

			<!-- 体重 -->
			<lb-picker ref="picker2" v-model="value2" mode="unlinkedSelector" :list="list2" @change="handleChange"
				@confirm="(value)=>handleConfirm(value,'weight')" @cancel="handleCancel">
			</lb-picker>
			<!--身高 -->
			<lb-picker ref="picker3" v-model="value3" mode="unlinkedSelector" :list="list3" @change="handleChange"
				@confirm="(value)=>handleConfirm(value,'height')"  @cancel="handleCancel">
			</lb-picker>

			<!-- 单选 -->
			<selecta ref="radio" :maskLayer="maskLayer" :current="radioIndex" :ydPopup="true" :checkedData="{}"
				:items="items" :mode="'radio'" :ifForm="false"  @descriptionAdd="descriptionAdd"
				@RadioData="RadioData"></selecta>
			<!-- 多选 -->
			<selecta ref="checkbox" :maskLayer="maskLayer" :ydPopup="false" :checkedData="{}" :items="items"
				:mode="'checkboxDan'" :healthName="healthName" :centerText="'多选'" :confirmText="'确认'"
				@descriptionAdd="descriptionAdd" :ifForm="false" @checkboxData="checkboxData" @other="other">
			</selecta>

			<!-- 公共滑动选择 -->
			<lb-picker ref="slidePicker" :value="publicSlideValue" mode="selector" :list="publicSlideList" @change="handleChange"
				@confirm="(value)=>handleConfirm(value,'slide')" @cancel="handleCancel">
			</lb-picker>

		   <!--健康信息-->
			<view class="in-every-particular" id="healthInfo" key="1">
				<view v-for="(item,idx) in result.healthInfo" :key="idx">
					<dev-list-layout v-if="idx==0" leftText="健康信息" leftColor="#2EA7E0" padding="0rpx 20rpx" :is-right-img="false"
						backgroundColor="linear-gradient(112deg, #D8EEE8 0%, #CFEBF8 100%)">
					</dev-list-layout>

					<dev-list-layout v-for="(items,idxs) in item.healthList" :key="idxs" :leftText="items.name" padding="0rpx 20rpx" :rightText="items.value?items.value:'待完善'"
					@tap="updateOption(items,idx,'healthInfo',item.healthList,idxs,item.healthName,items.value)">
					</dev-list-layout>

			     </view>
          </view>

		  <!--生活习惯-->
			<view class="in-every-particular" id="livingHabits">
			  	<view v-for="(item,idx) in result.livingHabits" :key="idx">
					<dev-list-layout v-if="idx==0" leftText="生活习惯" leftColor="#2EA7E0" padding="0rpx 20rpx" :is-right-img="false"
						backgroundColor="linear-gradient(112deg, #D8EEE8 0%, #CFEBF8 100%)">
					</dev-list-layout>
					<dev-list-layout v-for="(items,idxs) in item.healthList" :key="idxs" :leftText="items.name" padding="0rpx 20rpx" :rightText="items.value?items.value:'待完善'"
					@tap="updateOption(items,idx,'livingHabits',item.healthList,idxs,item.healthName,items.value)">
					</dev-list-layout>
				</view>
			</view>

			<!--心理状况-->
			<view class="in-every-particular" id="physiologyCondition" key="3">
			  	<view v-for="(item,idx) in result.physiologyCondition" :key="idx">
					<dev-list-layout v-if="idx==0" leftText="心理状况" leftColor="#2EA7E0" padding="0rpx 20rpx" :is-right-img="false"
						backgroundColor="linear-gradient(112deg, #D8EEE8 0%, #CFEBF8 100%)">
					</dev-list-layout>
					<dev-list-layout v-for="(items,idxs) in item.healthList" :key="idxs" :leftText="items.name" padding="0rpx 20rpx" :rightText="items.value?items.value:'待完善'"
					@tap="updateOption(items,idx,'physiologyCondition',item.healthList,idxs,item.healthName,items.value)">
					</dev-list-layout>
				</view>
			</view>
			<!--体检报告-->
			<view class="in-every-particular" id="bodyReport" key="4">
				<dev-list-layout @tap="moreAssessments()" leftText="体检报告" leftColor="#2EA7E0" rightTextColor="#2EA7E0" padding="0rpx 20rpx"
					rightText="更多" backgroundColor="linear-gradient(112deg, #D8EEE8 0%, #CFEBF8 100%)"
					imageHeightRight="30" imageWidthRight="30">
				</dev-list-layout>
				<dev-list-layout @tap="jumpDetails(PE)" imageWidthLeft="50" imageHeightLeft="50" height="136" padding="0rpx 20rpx"
					rightTextWidth="0" :isLeftImg="true" modeLeft="image"
					imageUrlLeft="shoppingMall/50C25E0F624A4159A7D9D654E79B2FD8.png" v-for="(PE,PEIndex) in medicalExaminationReport" :key="PEIndex">
					<template v-slot:left>
						<view style="margin-left: 20rpx;">
							<view class="hospital-name">
								{{PE.phyInstitution}}
							</view>
							<view class="time-of-physical-examination">
								体检时间：{{PE.phyTime}}
							</view>
						</view>
					</template>
				</dev-list-layout>

				<view class="upload-report" @tap.stop="jumpToUploadReport()">
					<dev-svg-image mode="image" imageUrl="shoppingMall/31201DBA55484CF19B4B09D5118B0093.png" width="44"
						height="44">
					</dev-svg-image>
					<text class="upload-text">上传报告</text>
				</view>

			</view>

			<!-- </scroll-view> -->

		</view>

		<view style="height: 50rpx;"></view>
		<dev-iphone-bottom></dev-iphone-bottom>

	</view>
</template>

<script>
	import devListLayout from '../components/dev-list-layout/dev-list-layout.vue'
	import selecta from '../components/lb-picker/select.vue';
	import lbPicker  from '../components/lb-picker/index.vue';

	import uLoading from "@/uview-ui/components/u-loading/u-loading.vue"


	export default {
		components: {
			devListLayout,
			lbPicker,
			selecta,
			uLoading,
		},
		data() {
			return {
				medicalExaminationReport:[],//体检报告
				navAllHeight: '',
				intoView:'basicInfo',
				loadingone: false, //懒加载
				result: '', //健康档案数据
			    healthName:'',
				allOther:{},//所有其他
				intoIndex:'bodyReport',
				cardIndex:0,//健康卡片位置
				list2: [],
				value2: ['请选择体重'],
				list3: [],
				value3: ['请选择身高'],
				starDate: '1900-12-31', //开始时间
				publicSlideValue: '', //公共的滑动选择回显值
				publicSlideList: [], //公共的滑动数据集合
				physiologyConditionPerfect:true,//心理状况
				livingHabitsPerfect:true,//生活习惯
				healthInfoPerfect:true,//健康信息
				pagetype:'',
				maskLayer: true,
				items: [], //公共的单选
				detailId: '', //单选滑动用到
				index1: '', //数组一级修改值
				index2: '', //数组二级修改值
				listtype: '',
				radioIndex: 9999, //视图未选择
				endTime: this.$basejs.thisdayFormat2(false), //结束时间默认今天
				sexList: [{
						label: '男',
						value: 1
					},
					{
						label: '女',
						value: 2
					}
				],
				healthCard:[
					{id:"basicInfo",name:'基本信息',url:'http://static.bsyjk.cn/health-records/82D9F3000C664FC088C0325DAA09648D.png',
					selectUrl:'http://static.bsyjk.cn/health-records/73ECC5603A204436AB4DACAD655FB8D5.png'},
					{id:"healthInfo",name:'健康信息',url:'http://static.bsyjk.cn/health-records/65BCFD2913894023A8E203A2973BD924.png'
					,selectUrl:'http://static.bsyjk.cn/health-records/7CEC028C358B45C29EF495507C964C6B.png'},
					{id:"livingHabits",name:'生活习惯',url:'http://static.bsyjk.cn/health-records/6ED00D31D657401A849FBFC168218BE7.png',
					selectUrl:'http://static.bsyjk.cn/health-records/B928ACFEAC49443B8020B564C55651DB.png'},
					{id:"physiologyCondition",name:'心理状况',url:'http://static.bsyjk.cn/health-records/821BCB3333D44DFA94EBEA700905FAD9.png',
					selectUrl:'http://static.bsyjk.cn/health-records/E7332AD80955422BA2DA78564A381D6C.png'},
					{id:"bodyReport",name:'体检报告',url:'http://static.bsyjk.cn/health-records/811B01AEB3944FDEB770BCF191F3EF41.png',
					selectUrl:'http://static.bsyjk.cn/health-records/E12994DBE88F4243968E183EEB38D171.png'}]
			};
		},
		onShow(){
		      // 动态获取滑动页面高度
		      const query = uni.createSelectorQuery().in(this);
		      query.select('.overall-data').boundingClientRect(data => {
				  console.info(data.height,"data.height");
		          this.aheight = data.height
		      }).exec();
			  this.userPhysicalReport();//获取体检报告
		    },
		onLoad(e) {
			//获取用户的健康档案信息
			this.userArchives();
			//初始化身高和体重
			this.initHeightWeight();
		},
		computed: {
			// 是否全部选中
			all_checked() {
				console.log(this.result,338)
				let healthInfo = this.result.healthInfo,
				livingHabits = this.result.livingHabits,
				physiologyCondition = this.result.physiologyCondition;
				this.healthInfoPerfect = this.perfectFun(healthInfo)//健康信息
				this.livingHabitsPerfect = this.perfectFun(livingHabits)//生活习惯
				this.physiologyConditionPerfect = this.perfectFun(physiologyCondition)//心理状况
			}
		},

		methods: {
			//跳转到详情界面
			jumpDetails(item) {
				if (item.fileType == 1) {
					this.$urouter.navigateTo({
						url: '/pagesMy/health-records/report-details',
						params: {
							url: item.reportUrl
						}
					});
				} else {
					wx.showLoading({
						title: 'pdf预览准备中',
					})
					//这一步是下载PDF
					wx.downloadFile({
						url: item.reportUrl,
						success(res) {
							console.log(res)
							const filePath = res.tempFilePath
							setTimeout(function() {
								//这一步是打开PDF
								wx.openDocument({
									fileType: "pdf",
									filePath: filePath,
									showMenu: true,
									success: function(res) {
										console.log(res)
										wx.hideLoading({
											success: function() {
												console.log('关闭');
											}
										})

									}
								})
							}, 300)
						},
						fail: function(e) {
							console.log(e, '网络错误');
						}
					})
				}
			},
			//跳转到上传报告
			jumpToUploadReport() {
				console.log('点击率')
				this.$urouter.navigateTo({
					url: '/pagesMy/health-records/upload-report',
					params: {}
				});
			},
			//更多报告
			moreAssessments(){
				this.$urouter.navigateTo({
					url: '/pagesMy/health-records/report',
					params: {
					}
				});
			},
			//获取体检报告
			userPhysicalReport() {
				this.$https.get(global.apiUrls.userPhysicalReport, {
					pageCurrent: 1,
					pageSize: 10,
					userId: global.userInfo.userId
				}).then(res => {
					if (res.data.code === 1000) {
						this.medicalExaminationReport = res.data.result.records;
					}
				})
			},
			//获取navAllHeight 信息
			information(e) {
				this.navAllHeight = e.navAllHeight;
			},
			initHeightWeight(){
			let list3 = [],
				list2 = [];
				for (let i = 100; i < 241; i++) { //身高数组
					list3.push({
						value: i,
						label: i
					})
				}
				for (let i = 25; i < 301; i++) { //体重
					list2.push({
						value: i,
						label: i
					})
				}
				let ninArr = [];
				for(let i = 0;i<10;i++){
					ninArr.push(i)
				}
				this.list2 = [list2,ninArr, ['kg']] //体重
				this.list3 = [list3, ['cm']] //身高数组
			},
			//获取健康档案
			userArchives() {
				this.loadingone = true;
				let _this = this;
				this.$api.get(global.apiUrls.userArchives + '/' + uni.getStorageSync(
						global.IS_DEV?'USER_DATA_BSY_T':'USER_DATA_BSY_Z').userId, {})
					.then(res => {
						if (res.data.code == 1000) {
							let result = res.data.result;
							_this.result = result;
							let weight = result.basicInfo.weight+'';
							_this.value1 = result.basicInfo.birthday
							if(weight){
								let strIndex = weight.indexOf(".") //.的索引
								console.log(strIndex,weight,'67777777')
								if (weight.startsWith('.', strIndex)) {//有.
								   weight = weight.split('.')
									_this.value2 = [weight[0]*1,weight[1]*1, 'kg']
									console.log(weight,[weight[0],weight[1], 'kg'],'有点681111')
								}else{
									_this.value2 = [result.basicInfo.weight, 'kg']
								}
							}
							console.log(result.basicInfo.weight,'674444444')
							_this.value3 = [result.basicInfo.height, 'cm']
							this.isLoadingOver = true;
						}
						_this.loadingone = false;
					}).catch(err => {})
			},
			//切换健康档案卡片
			switcHealthCard(item,index){
				this.$nextTick(()=> {
				  this.intoView = item.id;
				})
			   this.cardIndex = index;

			   uni.createSelectorQuery().select('.overall-data').boundingClientRect(data => {
			   　　　　uni.createSelectorQuery().select('#'+item.id).boundingClientRect(res => {
				         let height = 20;
			   　　　　　　uni.pageScrollTo({
			   　　　　　　　　scrollTop: res.top - data.top - height
			   　　　　　　})
			   　　　　}).exec()
			   　　}).exec()
			},
			//编辑用户基本信息选项
			clickInput(name) {
				console.log(name, "layout")
				switch (name) {
					case 'birthday':
						name = 'picker1';
						break;
					case 'height':
						name = 'picker3';
						break;
					case 'weight':
						name = 'picker2';
						break;
					case 'bloodType':
						name = 'picker5';
						break;
					case 'gender':
						name = 'sexPicker';
						break;
					default:
						return
				}
				this.$refs[name].show()
			},
			//编辑除用户基本信息选项
			updateOption(item, index1, type, healthList, index2, healthName, valueArr) {
				// id修改
				this.healthName = healthName
				console.log(healthName)
				this.result.healthName = healthName;
				this.result.paperId = item.paperId;
				this.result.kindId = type == 'livingHabits' ? 3 : 2
				// end
				this.listtype = type;
				this.index1 = index1;
				this.index2 = index2;
				if (valueArr) {
					this.valueArr = valueArr.split(',');
				}
				this.itemType = item.type;
				this.healthList = [];
				this.healthList.push(item); //点击的数据列表
				this.getByValueByPaperId(type,item.paperId,valueArr)
			},
			// 单选回调
			RadioData(data) {
				console.info(data,"RadioData")
				let listtype = this.listtype,
					index1 = this.index1,
					index2 = this.index2;
				this.result.detailId = data.data.detailId;
				this.result[listtype][index1].healthList[index2].value = data.data.value;
				this.result[listtype][index1].healthList[index2].detailId = data.data.detailId;
				// 请求修改接口
				this.updateByUserId(this.result)
			},
			//获取选项的答案
			getByValueByPaperId(type,paperId,valueArr) {
				let _this = this;
				this.$api.get(global.apiUrls.getByValueByPaperId + '/' + paperId, {})
					.then(res => {
						if (res.data.code == 1000) {
							let itemType = _this.itemType;
							let result = res.data.result;
							let thislist = [];
							let healthList = _this.healthList; //当前选中数据列表
							if (itemType == 1) { //选择输入
								let value = result[0].value.split('-');
								let i = parseInt(value[0]), //最小值
									maxnum = parseInt(value[1]), //最大值
									publicSlideList = []; //公用list
								for (i; i < maxnum; i++) {
									publicSlideList.push({
										label: i+'',
										value: i+''

									})
								}
                                _this.publicSlideValue = valueArr;
								_this.detailId = result[0].detailId;
								_this.publicSlideList = publicSlideList
								_this.$refs['slidePicker'].show()
								console.log(publicSlideList, maxnum)
							} else if (itemType == 2) { //手动输入
							} else if (itemType == 3) { //单选
								let current = '';
								for (let i = 0; i < result.length; i++) {
									let isRepea = false; //判断是否重复
									result[i].type = type;
									for (let j = 0; j < healthList.length; j++) {
										if (result[i].detailId == healthList[j].detailId) {
											console.log('重复！！！！！！！！！！！！！！', i)
											isRepea = true //重复
											current = i //重复索引
											break; //结束
										}
									}
									if (isRepea) { //选中
										result[i].checked = true
									} else { //未选中
										result[i].checked = false
									}
									result[i].label = result[i].value
								}
								_this.items = result;
								console.log(current, 331)
								_this.radioIndex = current
								_this.$refs['radio'].show()
							} else if (itemType == 4) { //多选
								let valueArr = _this.valueArr,
								qtArr = JSON.parse(JSON.stringify(_this.valueArr)),
								qtIndex = 0;
								console.log('1563 aaaaaaaaaaaaaa', result, valueArr)
								for (let i = 0; i < result.length; i++) {
									let isRepea = false; //判断是否重复
									if(result[i].value == '其他'){
										qtIndex = i
									}
									for (let j = 0; j < valueArr.length; j++) {
										if (result[i].value == valueArr[j]) {
											console.log('重复！！！！！！！！！！！！！！', i)
											isRepea = true //重复
											delete qtArr[j]
											break; //结束
										}
									}
									if (isRepea) { //选中
										result[i].checked = true
									} else { //未选中
										result[i].checked = false
									}
									result[i].label = result[i].value
								}
								let qtArrq = []
								for(let i = 0;i<qtArr.length;i++){
									if(qtArr[i] != ''&&qtArr[i]!= null){
										qtArrq.push(qtArr[i])
									}
								}
								if(qtArrq.length == 1){
									result[qtIndex].checked = true
									setTimeout(e=>{
										_this.$refs.checkbox.otherValueFun(qtArrq[0])
									},500)
								}else{
									setTimeout(e=>{
										_this.$refs.checkbox.otherValueFun('')
									},500)
								}
								console.log(qtArrq,69111111)
								_this.items = result;
								if (paperId == 5) {
									_this.$refs['checkbox'].cascadeShow()
								}
								// else if(paperId == 7){
								// 	_this.$refs['checkbox'].cascadeShowc()
								// }
								else {
									_this.$refs['checkbox'].show()
								}
							} else if (itemType == 5) { //时间

							} else if (itemType == 7) {

							}
						}
					}).catch(err => {})
			},
			// 多选提交
			checkboxData(data) {
				console.log(data)
				let listtype = this.listtype,
					index1 = this.index1,
					index2 = this.index2;
				if (data.type == 'formhide') { //多选提交
					let items = this.items,
						valueArr = [],
						detailId = '';
					for (let i = 0; i < items.length; i++) {
						if (items[i].checked&&items[i].value=='其他') {
							valueArr.push(this.allOther[listtype]?this.allOther[listtype].otherValue:items[i].value)
							detailId = items[i].detailId
						}else if (items[i].checked){
							valueArr.push(items[i].value)
							detailId = items[i].detailId
						}
					}
					this.result.detailId = detailId;
					this.result[listtype][index1].healthList[index2].value = valueArr.join(',')
					this.updateByUserId(this.result)
				} else if (data.type == 'reset') {
					for (let i = 0; i < this.items.length; i++) {
						this.items[i].checked = false
					}
				} else {
					console.log(this.items[data.index].value == '无' || data.value == '9999999999999999', '381111111111')
					if (this.items[data.index].value == '无' || data.value == '9999999999999999') {
						if (this.items[data.index].checked == false) {
							for (let i = 0; i < this.items.length; i++) {
								this.items[i].checked = false
							}
						}
					}
					if (this.items[0].value == '无' && this.items[0].checked == false || data.index == 0) { //没选中无的状态
						this.items[data.index].checked = !this.items[data.index].checked
					} else if (this.items[0].value == '无' && this.items[0].checked == true) { //无选中状态
						this.items[0].checked = false
						this.items[data.index].checked = !this.items[data.index].checked
					} else { //没有无 的状态
						let noIndex = 0;
						for(let i = 0;i<this.items.length;i++){
							if(this.items[i].value == '无'){
								noIndex = i
							}
						}
						this.items[noIndex].checked = false//无取消选中
						this.items[data.index].checked = !this.items[data.index].checked
					}

				}
			},
			handleChange(e) {

			},
			handleCancel(e) {

			},
			other(e){
                console.info(e,"e----------222-->")
				this.allOther[this.listtype]= {
					otherValue:e.detail.value
				}
			},
			//判断是否选择完成
			perfectFun(dataList){
				console.info(dataList,"dataList--->")
				if (!dataList) return false;
				let perfect = false;
				for(let i = 0;i<dataList.length;i++){
					let healthList = dataList[i].healthList;
					for(let j = 0;j<healthList.length;j++){
						if(healthList[j].value == ''||healthList[j].value == null){//有未完善
							perfect = true
						}
					}
				}
				console.log(perfect,350000000)
				return perfect
			},
			//修改选项
			handleConfirm(value,name){
			   switch (name) {
			   	case 'birthday':
				     this.result.basicInfo.birthday = value.value
			   		 this.updateBasicInfo()
			   	case 'height':
			   		this.result.basicInfo.height = value.value[0]
			   		this.updateBasicInfo()
			   		break;
			   	case 'weight':
			   		this.result.basicInfo.weight = value.value[0]+'.'+value.value[1]
			   		this.updateBasicInfo()
			   		break;
			   	case 'gender':
				     this.result.basicInfo.sex=value.value;
			   		 this.updateBasicInfo();
			   		break;
				case 'slide':
				     this.updatePublicSlide(value);
						break;
			   	default:
			   		return
			   }

			},
			// 公用的滑动控件
			updatePublicSlide(e) {
				let value = e.value; //获取修改value
				let result = this.result,
					listtype = this.listtype,
					index1 = this.index1,
					index2 = this.index2;
				this.result.detailId = this.detailId; //result提交id
				this.result[listtype][index1].healthList[index2].value = value; //视图
				this.result[listtype][index1].healthList[index2].detailId = this.detailId; //视图组id
				// console.log(value,'公用的滑动控件')
				// 请求修改接口
				this.updateByUserId(this.result)
			},
			updateBasicInfo(){
				this.result.paperId = ''
				this.result.kindId = 1
				this.result.detailId = ''
				this.result.healthName = '基本信息'
				this.updateByUserId(this.result)
				if(this.result.basicInfo.sex&&this.result.basicInfo.birthday&&this.result.basicInfo.height&&this.pagetype == 'perfect'){
					wx.showModal({
						title: '提示',
						content: '可以继续测量啦!',
						showCancel: false,
						success: function(res) {
							uni.navigateBack({
								delta: 1
							});
						}
					})
				}
			},
		    // 修改昵称
		    nameAlter(e) {
		    	console.log(e)
		    	let value = e.detail.value;
		    	this.result.basicInfo.userName = value
		    	this.result.paperId = ''
		    	this.result.kindId = 1
		    	this.result.detailId = ''
		    	this.result.healthName = '基本信息'
		    	this.updateByUserId(this.result)
		    },
			updateByUserId(phrVO) {
				let _this = this;
				let loginKey = global.IS_DEV?'USER_TOKEN_BSY_T':'USER_TOKEN_BSY_Z'
				uni.request({
					data: phrVO,
					header: {
						'Authorization': uni.getStorageSync(loginKey),
						'userSource': 1, //用户类型 1:C端用户  2:员工
						'content-type': 'application/json'
					},
					method: 'POST',
					url: global.host+'health-service/userArchives/updateByUserId',
					success(res) {
						if (res.data.code == 1000) {
							_this.userArchives()
						}
					},
                    error(err) {
                        console.info(err,"err-->")
                    }
				})
				// this.$api.post(global.apiUrls.updateByUserId, fdata)
				// 	.then(res => {
				// 		if (res.data.code == 1000) {

				// 		}
				// 	}).catch(err => {})
			},
		}
	}
</script>

<style lang="scss">

	//头部导航栏
	.head-navigation {
		position: fixed;
		white-space: nowrap;
		width: 100%;
		background-color: #f5f5f5;
		padding: 16rpx 20rpx;
		z-index: 100;

		.every-scroll-view {
			display: inline-block;
			margin-right: 20rpx;
			position: relative;

			.every-card-box {
				width: 150rpx;
				height: 118rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				background: #FFFFFF;
				font-size: 26rpx;
				font-weight: 400;
				color: #333333;
				box-shadow: 0rpx 2rpx 20rpx 0rpx rgba(173, 173, 173, 0.25);
				border-radius: 19rpx;
			}

			.choose-card-box {
				width: 150rpx;
				height: 118rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				background: linear-gradient(180deg, #0BCEDE 0%, #2DAADD 100%);
				font-size: 26rpx;
				font-weight: 400;
				color: #fff;
				box-shadow: 0rpx 2rpx 20rpx 0rpx rgba(173, 173, 173, 0.25);
				border-radius: 19rpx;
			}

			.triangle {
				position: absolute;
				width: 0;
				height: 0;
				border-left: 12rpx solid transparent;
				border-right: 12rpx solid transparent;
				border-bottom: 14rpx solid #2DAADD;
				position: absolute;
				bottom: 0rpx;
				left: 64rpx;
				transform: rotate(180deg);
				z-index: 10000;
			}
		}
	}



	.overall-data {
		padding: 1rpx 24rpx;
		.in-every-particular {
			border-radius: 16rpx 16rpx 0rpx 0rpx;
			margin-top: 34rpx;
			overflow: hidden;
			background-color: #fff;
		}
	}

	.hospital-name {
		font-size: 30rpx;
		font-weight: 400;
		color: #333333;
	}

	.time-of-physical-examination {
		font-size: 24rpx;
		font-weight: 400;
		color: #333333;
	}

	//上传报告
	.upload-report {
		width: 610rpx;
		height: 130rpx;
		border-radius: 10rpx;
		border: 1rpx dashed #979797;
		margin: 57rpx 46rpx;
		display: flex;
		align-items: center;
		justify-content: center;

		.upload-text {
			margin-left: 30rpx;
			font-size: 30rpx;
			font-weight: 400;
			color: #4A4A4A;
		}
	}
</style>
